from pydantic import BaseModel, Field
from fastapi import Query

InOpenDoor = Query(
    ...,
    title="密码",
    description="解锁门禁的密码",
    example="12345678",
    regex="^\d{8}$"
)

InPassWord = Query(
    ...,
    title="密码字符",
    description="单个密码字符",
    example="1",
    regex="[0-9]"
)

InChangePass = Query(
    ...,
    title="密码",
    description="更改门禁的密码",
    example="12345678",
    regex="^\d{8}$"
)


class OutOpenDoor(BaseModel):
    status: str = Field(..., description="返回的门开关状态", example='开启')
    time: float = Field(..., description="返回服务器的时间", example=1635247642749)


class OutPassWord(BaseModel):
    password: str = Field(..., description="实时返回密码框中的密码", example="12345678")
    time: float = Field(..., description="返回服务器的时间", example=1635247642749)


class OutChangePass(BaseModel):
    status: bool = Field(True, description="返回的密码是否成功修改", example=True)
    time: float = Field(..., description="返回服务器的时间", example=1635247642749)
